<?php
/**
 * Created by PhpStorm.
 * User: gakuin
 * Date: 16/8/28
 * Time: 下午12:13
 */
use app\assets\AppAsset;
use yii\widgets\ActiveForm;
use yii\helpers\Html;

AppAsset::register($this);
$base =  Yii::$app->request->baseUrl;
AppAsset::addCss($this, $base . "/css/register.css");
AppAsset::addCss($this, $base . "/css/login.css");
$this->title = '找回密码';
?>
<div id="layout">
    <?php $form = ActiveForm::begin([
        'id' => 'reset-form',
        'options' => ['class' => 'form-horizontal'],
        'fieldConfig' => [
            'template' => "{label}\n<div class=\"col-lg-3\">{input}</div>\n<div class=\"col-lg-8\">{error}</div>",
            'labelOptions' => ['class' => 'col-lg-1 control-label'],
        ],
    ]); ?>
    <div style="margin-bottom: 10%">
        <span style="padding-left: 10%;position: relative;top: 5px;font-size: 16px"><?= $mobilestr?><span>
        <span style="float: right"><button id="sms-btn" type="button" class="btn btn-success pull-right;" >获取送验证码</button></span>
    </div>
    <?= $form->field($model, 'code')->textInput(['placeholder'=>"请输入验证码"]) ?>

    <?= Html::submitButton('下一步', ['class' => 'submit', 'type' => 'button']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>
<script type="text/javascript">
    $('#sms-btn').click(function(){
        $.ajax({
            type : "POST",
            url :"sms",
            data:{
                'tel':<?= $mobile ?>

            },
            success:function(da){
                var long = 60;
                var btn = $('#sms-btn');
                btn.prop({disabled: true});
                btn.removeClass('btn-success');
                btn.html(long + "s后重新发送");
                var timer = setInterval(function () {
                    if (long > 0) {
                        long--;
                        btn.html(long + "s后重新发送");
                    } else {
                        btn.html('重新发送');
                        btn.prop({disabled: false});
                        btn.addClass('btn-success');
                        clearInterval(timer);
                    }
                }, 1000);
            }

        });
    });
</script>


